package chamber.n01;

import chamber.n01.guice.Module01;
import chamber.n01.prime.Prime;
import com.google.inject.Inject;
import common.Program;
import common.ProgramFactory;
import common.io.console.Terminal;

/**
 * Created by Gerardo on 2/8/14.
 */
public class Chamber01 implements Program {
	private final Terminal terminal;
	private final Prime prime;

	@Inject
	public Chamber01(final Terminal terminal, final Prime prime) {
		this.terminal = terminal;
		this.prime = prime;
	}

	public static void main(final String[] args) {
		Program program = ProgramFactory.create(Chamber01.class, new Module01());
		program.execute();
	}

	@Override
	public void execute() {
		final String line = terminal.readLine("write a number: ");
		final boolean isPrime = prime.apply(Long.parseLong(line));
		terminal.printf("%s prime", isPrime? "is" : "isn't");
	}
}
